package core

import b3 "gitee.com/zhenghexcs/bevtreestatus"

/*
不设置IsOpen的基类
不会调用OnOpen 、OnClose
*/
type BaseNodeNoState struct {
	BaseNode
}

/**
 * Wrapper for enter method.
 * @method _enter
 * @param {Tick} tick A tick instance.
 * @protected
**/
func (this *BaseNodeNoState) _enter(tick *Tick) {
	tick._enterNode(this)
	this.OnEnter(tick)
}

/**
 * Wrapper for close method.
 * @method _close
 * @param {Tick} tick A tick instance.
 * @protected
**/
func (this *BaseNodeNoState) _close(tick *Tick) {
	tick._closeNode(this)
	// tick.Blackboard.SetMem(this.IsOpenKey, false)
	// tick.Blackboard.Set("isOpen", false, tick.tree.id, this.id)
	// this.OnClose(tick)
}
func (this *BaseNodeNoState) _execute(tick *Tick) b3.Status {
	//fmt.Println("_execute :", this.title)
	// ENTER
	this._enter(tick)

	// // OPEN
	// if !tick.Blackboard.GetBool(this.IsOpenKey) {
	// this._open(tick)
	// }

	// TICK
	var status = this._tick(tick)

	/*
		因为没有状态节点，在enter里面会把自己添加到数组中
						在close里面会把自己移除，而不做其他事情
	*/
	// CLOSE
	// if status != b3.RUNNING {
	this._close(tick)
	// }

	// EXIT
	this._exit(tick)

	return status
}
func (this *BaseNodeNoState) Execute(tick *Tick) b3.Status {
	return this._execute(tick)
}
